package com.ld.wms.thread;

import com.ld.wms.business.log.service.CameraMonitorInfoService;
import com.ld.wms.business.log.vo.req.CameraMonitorInfoReqVo;
import com.ld.wms.cameraMonitor.NetSDKDemo.ClientDemo;
import com.ld.wms.cameraMonitor.NetSDKDemo.VideoDemo;
import com.ld.wms.properties.LDProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class BackgroundThreadTasks {

    @Autowired
    private LDProperties ldProperties;

    @Autowired
    private CameraMonitorInfoService cameraMonitorInfoService;

    public void ExpireInventoryList() {
        while (true) {
            try {
                Thread.sleep(8000);
                //equipmentService.backgroundUpdateEquipmentStatus();
            } catch (Exception e) {
                log.error("backgroundUpdateEquipmentStatus", e);
            }
        }
    }

    public void startCameraMonitor() {
        try {
            Thread.sleep(5000);
        } catch (Exception e) {

        }
        log.info("自动录制开启成功！");
        /*while (true) {
            try {
                if (VideoDemo.cameraMonitorConnectStatus == 1) {
                    String historyStoragePath = ldProperties.getCameraMonitor().getHistoryStoragePath();
                    int duration = ldProperties.getCameraMonitor().getDuration();
                    String filePath = ClientDemo.start(historyStoragePath);
                    Thread.sleep(duration * 1000);
                    ClientDemo.end();
                    // 监控信息记录
                    CameraMonitorInfoReqVo reqVo = new CameraMonitorInfoReqVo();
                    reqVo.setDuration(duration);
                    reqVo.setFilePath(filePath);
                    cameraMonitorInfoService.add(reqVo);
                } else {
                    log.info("监控连接断开···");
                    Thread.sleep(1000);
                    // 0则第一次未登录成功需要重新登录
                    if (ClientDemo.loginFlag == 0) {
                        log.info("第一次未登录,重新登录中！");
                        ClientDemo.init();
                    }
                }
            } catch (Exception e) {
                log.error("startCameraMonitor", e);
            }
            // 清理超过的条数
            cameraMonitorInfoService.clearHistoryVideo();
        }*/

    }

}
